<?php

class ShowController extends CommonController{
	
	private $_model;
	
	public function __init(){
		
		$this->_model=K('GDGView');
	}
	
	public function index(){
		
		$gid=Q('get.gid');
		$data=$this->_model->get_all_data(array('good.gid'=>$gid));
		
		foreach ($data as $k => $v) {
			$data[$k]['sthumb']=explode(',', $v['sthumb']);
			$data[$k]['mthumb']=explode(',', $v['mthumb']);
		}
		$where='gid =' . $gid . ' and tptype = "规格"';
		
		$attr=K('GTpropertyView')->get_all_data($where,'gpid');
//		p($attr);
		
		$arr=array();
		foreach ($attr as $k => $v) {
			$arr[$v['tpid']][]=$v;
		}
		
		$attr=array();
		foreach ($arr as $k => $v) {
			$attr[]=array(
				'tpname'=>K('Tproperty')->where(array('tpid'=>$k))->getField('tpname'),
				'tpvalue'=>$v,
			);
		}
		
		$this->assign('data',$data);
		$this->assign('attr',$attr);
		$this->dis('Show');
	}
	
	public function ajax_check_inventory(){
		
		if(!IS_AJAX) $this->error('非法请求');
		
		$apid=Q('post.gpid');
		$gid=Q('post.get');
		$where='apid = "' . $apid . '" and gid= "' . $gid . '"';
		$data=K('Glist')->get_one_data($where);
		$data=$data['glinventory'];
		$this->ajax($data);
		/*p($apid);
		p($data['glinventory']);
		echo $cid;*/
	}
	
	
	
	
}

































